local desc_huanhua = [[
  # 幻化之战简介

  ---

  ## 身份说明

  游戏由2~10名玩家进行，玩家们各自为战，力求活到最后！

  ---

  ## 游戏目标

  杀死所有阵营与你不同的角色
  
  ---

  ## 击杀奖惩
  
  当一名角色死亡时，杀死其的角色摸三张牌。

  ---

  ## 新生

  所有角色以自己的头像为武将，体力上限、体力值会被调整到4点、护甲会归零。

  ---

  ## 普通模式（默认）

  每名角色通过造成伤害来获得「灵力」，通过消耗「灵力」获得技能（最多3个，超过则由角色选择一个失去）和摸牌。

  游戏开始时，每名角色各获得2枚「灵力」，从3个随机技能中选1个获得（不计入上限），或摸两张牌。

  每当你造成1点伤害后，你获得1枚「灵力」。

  回合开始时，你可以移除2枚「灵力」，从3个随机技能中选1个获得。

  出牌阶段限一次，你可以移除任意枚「灵力」，摸等量的牌。

  ---

  ## 狂暴模式（开启房间的双将选项解锁）

  每轮开始时，所有角色各自从3个随机技能中选1个获得，或者摸两张牌。

]]

-- 模式逻辑
local huanhua_getLogic = function()
  ---@class GameLogic
  local huanhua_logic = GameLogic:subclass("huanhua_logic")
  
  -- 大混战呗
  function huanhua_logic:assignRoles()
    local room = self.room
    local n = #room.players
    for i = 1, n do
      local p = room.players[i]
      p.role = "hidden"
      p.role_shown = true
      room:broadcastProperty(p, "role")
    end
    self.start_role = "hidden"
    -- for adjustSeats
    room.players[1].role = "lord"
  end
  
  -- 皮套自备
  function huanhua_logic:chooseGenerals()
    local room = self.room
    local lord = room:getLord()
    room:setCurrent(lord)
    lord.role = "hidden"
    local players = room.players
    for _, p in ipairs(players) do
      local avatar = p._splayer:getAvatar()
      if avatar == "anjiang" then avatar = "guanyu" end
      local avatar_general = Fk.generals[avatar] or Fk.generals["guanyu"]
      room:setPlayerGeneral(p, avatar_general.name, true)
      room:broadcastProperty(p, "general")
      room:setPlayerProperty(p, "shield", 0)
      room:setPlayerProperty(p, "maxHp", 4)
      room:setPlayerProperty(p, "hp", 4)
    end
    room:doBroadcastNotify("ShowToast", Fk:translate("huanhua_intro"))
  end
  
  -- 体力初始化（上面已经做了）
  function huanhua_logic:broadcastGeneral()
  end
  
  -- 技能初始化
  function huanhua_logic:attachSkillToPlayers()
  end

  return huanhua_logic
end

-- 游戏模式
local huanhua_mode = fk.CreateGameMode{
  name = "huanhua_mode",
  minPlayer = 2,
  maxPlayer = 10,
  rule = "#huanhua_rule&",
  logic = huanhua_getLogic,
  surrender_func = function(self, playedTime)
    local surrenderJudge = { { text = "#left two alive", passed = #Fk:currentRoom().alive_players == 2 } }
    return surrenderJudge
  end,
  winner_getter = function(self, victim)
    local room = victim.room
    local alive = table.filter(room.alive_players, function(p)
      return not p.surrendered
    end)
    if #alive > 1 then return "" end
    alive[1].role = "renegade" --生草
    return "renegade"
  end,
}

Fk:loadTranslationTable{
  ["huanhua_mode"] = "幻化之战",
  [":huanhua_mode"] = desc_huanhua,
  ["huanhua_intro"] = "运用巧妙的技能组合，击败所有对手吧！",
  ["#left two alive"] = "仅剩两名角色存活",
}

return huanhua_mode